package com.study;

import java.util.UUID;
import java.util.concurrent.CountDownLatch;

public class WorkerUuidCount extends Thread {
    private String name;
    private long time;
    private CountDownLatch countDownLatch;

    public WorkerUuidCount(String name, long time, CountDownLatch countDownLatch) {
        this.name = name;
        this.time = time;
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        try {
//            System.out.println(name + "开始工作");
//            Thread.sleep(time);
//
            int index = 0;
            while(index < 10000){
                String uuid = CountDownLatchTest3.getUuid();
                CountDownLatchTest3.map.put(uuid, name+"-"+index);
                index++;
            }
//            System.out.println(name + "工作完成, 耗时："+ time);
            countDownLatch.countDown();
//            System.out.println(name+":" + countDownLatch.getCount());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        System.out.println(uuid);
    }
}